import java.util.*;


class PersonOverride{
    private String name;
    private int age;
    private boolean gender;
    public PersonOverride() {
        this("default", 1, true);
    }
    public PersonOverride(String name,int age,boolean gender) {
        this.name = name;
        this.age = age;
        this.gender = gender;
    }
    @Override
    public String toString() {
        return this.name+"-"+this.age+"-"+this.gender;
    }
    @Override
    public boolean equals(Object o) {
        if (this == o){
            return true;
        }
        if(o == null)
        {
            return false;
        }
        if (this.getClass() != o.getClass()){
            return false;
        }
        PersonOverride p = (PersonOverride) o;
        return Objects.equals((this.name), p.name) && this.gender == p.gender && this.age==p.age;
    }
}
public class Main{
    public static void main(String [] args){
        Scanner in=new Scanner(System.in);
        int n1 = in.nextInt();
        in.nextLine();
        PersonOverride[] persons1 = new PersonOverride[n1];
        for(int i=0;i<n1;i++) {
            persons1[i] = new PersonOverride();
        }
        int n2 = in.nextInt();
        in.nextLine();
        PersonOverride[] persons2 = new PersonOverride[n2];
        int len2=0;
        for(int i=0;i<n2;i++) {
            String name = in.next();
            int age = in.nextInt();
            boolean gender = in.nextBoolean();
            in.nextLine();
            PersonOverride p = new PersonOverride(name,age,gender);
            boolean flag = true;
            for(int j=0;j<len2;j++) {
                if(persons2[j].equals(p)) {
                    flag = false;
                    break;
                }
            }
            if(flag) {
                persons2[len2] = p;
                len2++;
            }
        }
        for(PersonOverride p:persons1) {
            System.out.println(p);
        }
        for(int i=0;i<len2;i++) {
            System.out.println(persons2[i]);
        }
        System.out.println(len2);
        System.out.println(Arrays.toString(PersonOverride.class.getConstructors()));
    }
}